#ifdef __GNUG__
#pragma implementation
#endif

#include "WindowBorder.h"

#include "Class.h"
#include "Buttons.h"
#include "Box.h"
#include "Window.h"
#include "TextItem.h"
#include "Menu.h"
#include "Env.h"
#include "Look.h"
#include "OrdColl.h"

//---- WindowBorder ------------------------------------------------------------

NewMetaImpl0(WindowBorder,CompositeVObject);

WindowBorder::WindowBorder(bool fix, VObject *title, VObject *inner)
				: CompositeVObject(cIdNone, inner, title, 0)
{
	fixed= fix;
}

WindowBorder::~WindowBorder()
{
	Remove(At(0));  // avoid deletion of inner
}

void WindowBorder::SetTitle(const char*)
{
}

Command *WindowBorder::DoMenuCommand(int cmd)
{
	Window *w= GetWindow();
	Manager *m= 0;

	if (w == 0)
		return CompositeVObject::DoMenuCommand(cmd);
		
	m= (Manager*) w->GetNextHandler();

	switch (cmd) {
	case cTOP:
		w->Top();
		break;
	case cBOTTOM:
		w->Bottom();
		break;
	case cREDISPLAY:
		w->ForceRedraw();
		break;
	case 4711:
		if (m)
			m->Hide();
		break;
	case 4712:
		if (m)
			m->Show();
		break;
	default:
		return CompositeVObject::DoMenuCommand(cmd);
	}
	return gNoChanges;
}

void WindowBorder::Control(int id, int part, void *vp)
{
	switch (id) {
	case cIdBottom:
		GetWindow()->Bottom();
		break;
	case cIdCloseBox:
		if (part == cPartAction)
			CompositeVObject::Control(cCLOSE, part, vp);
		else
			CompositeVObject::Control(id, part, vp);
		break;
	default:
		CompositeVObject::Control(id, part, vp);
		break;
	}
}

